<div>beforeunload demo.</div>
<script>
window.addEventListener('beforeunload', event => {
  console.log('Before called');
});
</script>

